package com.we.wecc.bk.mid.impl;

import com.we.wecc.bk.db.model.BankCard;
import com.we.wecc.bk.mid.service.BankService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;



import static com.x.share.mid.utils.BankCardUtils.checkBankCard;
import static com.x.share.mid.utils.BankCardUtils.getBankCardCheckCode;
import static com.x.share.mid.utils.BankCardUtils.getNameOfBank;
@Service
public class BankServiceImpl implements BankService{

    Logger logger = LoggerFactory.getLogger(getClass());

    @Override
    public BankCard verifyBankNo(String bankNo) {
        char checkCode = getBankCardCheckCode(bankNo.substring(0, bankNo.length() - 1));
        Boolean flag = checkBankCard(bankNo);
        String cardSpecies = getNameOfBank(bankNo);
        logger.info("银行卡号：" + bankNo + "  check code: " + checkCode + " 是否为银行卡: " + flag + " 卡种：" + cardSpecies);
        BankCard bc = new BankCard();
        bc.setBankNo(bankNo);
        bc.setCheckCode(checkCode);
        bc.setFlag(flag);
        bc.setCardSpecies(cardSpecies);
        return bc;
    }
}
